import openpyxl
#打开工作表
wb = openpyxl.load_workbook('example.xlsx')
#读取工作簿
sheet = wb['Sheet1']
#单元格取值
cell = sheet['A1']
#print(cell)
print(sheet['A1'].value)
valueA1 = cell.value
#print(valueA1)
cell2 = sheet['b1']
cell2.value
print('Row %d Column %d is %s'%(cell2.row, cell2.column, cell2.value))

#单元格取值
value3 = sheet.cell(row = 1, column = 2)
print(type(value3))
print(value3)
for i in range(1,8,2):
    print(i, sheet.cell(row=i, column = 2).value)

#确定工作表范围
print('Max Row is %d.'%sheet.max_row)
print('Max Column is %d.'%sheet.max_column)

#列Column字母和数字间的转换
from openpyxl.utils import get_column_letter
from openpyxl.utils import column_index_from_string
print(get_column_letter(1))
print(get_column_letter(1200))
print(get_column_letter(sheet.max_column))
print(column_index_from_string('ABC'))